package com.jz.community.basecomm.utils.permission;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * @Description: 权限组
 * @Author: weilu
 * @Time: 2018/3/7 15:49.
 */

public class PermissionGroup {

    /**
     * 读写日历
     */
    public static final String[] CALENDAR = new String[]{
            Permission.READ_CALENDAR,
            Permission.WRITE_CALENDAR};

    /**
     * 相机
     */
    public static final String[] CAMERA = new String[]{Permission.CAMERA};

    /**
     * 读写联系人
     */
    public static final String[] CONTACTS = new String[]{
            Permission.READ_CONTACTS,
            Permission.WRITE_CONTACTS,
            Permission.GET_ACCOUNTS};

    /**
     * 读位置信息
     */
    public static final String[] LOCATION = new String[]{
            Permission.ACCESS_FINE_LOCATION,
            Permission.ACCESS_COARSE_LOCATION};

    /**
     * 使用麦克风
     */
    public static final String[] MICROPHONE = new String[]{Permission.RECORD_AUDIO};

    /**
     * 读电话状态、打电话、读写电话记录
     */
    public static final String[] PHONE = new String[]{
            Permission.READ_PHONE_STATE,
            Permission.CALL_PHONE,
            Permission.READ_CALL_LOG,
            Permission.WRITE_CALL_LOG,
            Permission.ADD_VOICEMAIL,
            Permission.USE_SIP,
            Permission.PROCESS_OUTGOING_CALLS};

    /**
     * 传感器
     */
    public static final String[] SENSORS = new String[]{Permission.BODY_SENSORS};

    /**
     * 读写短信、收发短信
     */
    public static final String[] SMS = new String[]{
            Permission.SEND_SMS,
            Permission.RECEIVE_SMS,
            Permission.READ_SMS,
            Permission.RECEIVE_WAP_PUSH,
            Permission.RECEIVE_MMS};

    /**
     * 读写存储卡
     */
    public static final String[] STORAGE = new String[]{
            Permission.READ_EXTERNAL_STORAGE,
            Permission.WRITE_EXTERNAL_STORAGE};

    
    public static String[] permissionGroups(String[]... groups) {
        List<String> permissionList = new ArrayList<>();
        for (String[] group : groups) {
            permissionList.addAll(Arrays.asList(group));
        }
        return permissionList.toArray(new String[permissionList.size()]);
    }

}
